def strcmp(self, other):
    if self == other:
        return 0
    if len(self) < len(other):
        return 0 - ord(other[len(self)])
    elif len(self) > len(other):
        return ord(self[len(other)])
    else:
        for i in range(len(self)):
            if self[i] != other[i]:
                return ord(self[i]) - ord(other[i])


def resolution1():
    T = int(input())
    while T:
        s, t = input().split(' ')
        print(strcmp(s, t))
        T -= 1


if __name__ == '__main__':
    resolution1()
